package server

import (
	"log"

	"github.com/dheisomgomes/codeapi/server/routers"
	"github.com/gin-gonic/gin"
)

type Server struct {
	port   string
	server *gin.Engine
}

func NewServer(p string) Server {
	return Server{
		port:   p,
		server: gin.Default(),
	}
}

func (s *Server) Run() {
	router := routers.ConfigRouters(s.server)
	log.Print("Server running at port:", s.port)
	err := router.Run(":" + s.port)
	if err != nil {
		log.Fatal("Error:", err)
	}
}
